const { defineConfig } = require('@vue/cli-service')
// 用于返回指定文件名的绝对路径
const path = require('path')
const resolve = (name) => (
  path.join(__dirname, name)
)
module.exports = defineConfig({
  transpileDependencies: true,
  // 提供一个本地服务器，并且对请求进行代理
  devServer: {
    host: 'localhost',
    port: 6363,
    open: true,
    proxy: {
      '/api': {
        target: 'https://www.fastmock.site/mock/cec04a4219fe223a5d5b3de3c204297c/api',
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/api'
        }
      }
    }
  },
  // 禁用保存时的代码风格检查
  lintOnSave: true,
  // 目录路径设置别名
  chainWebpack: (config) => {
    config.resolve.alias
      .set('@', resolve('./src'))
      .set('@v', resolve('./src/views'))
  }
})
